package operation;

import Book.Book;
import Book.BookList;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA
 * Description
 * User:华为
 * Date:2024/10/18
 * Time:21:11
 */
public class BorrowOperation implements IOperation{
    @Override
    public void work(BookList bookList) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入你想要借书的书名");
        String name = scanner.nextLine();
        int currentsize = bookList.getUsedSize();
        for (int i = 0; i < currentsize; i++) {
             Book book = bookList.getBook(i);
             if(book.getName().equals(name)){
                 book.setBorrowed(true);
                 System.out.println("已经成功借阅");
                 return;
             }
        }
        System.out.println("未找到想借阅的书");
    }
}
